﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.IO;
using System.Text;

    using System;
    using System.Collections;
    using System.IO;
    using System.Text.RegularExpressions;
using System.Net;
using System.Drawing;
using System.Threading;
public partial class 字符串比较 : System.Web.UI.Page
{
    //用于字符串比较的线程 
    System.Threading.Thread myThr;
    private RegexMy MyReg = new RegexMy();

    public Int16 线程数 = 10;

    int 搜索重复 = 0;

    MultiPageAutoGet 用于测试用类型 = new MultiPageAutoGet();

    protected void Page_Load(object sender, EventArgs e)
    {
        用于测试用类型.GetMain(1, MyReg.RegexToArray(@"[^\r\n]+", this.txtNewsList.Text), Url.Text, 线程数, 搜索重复);


        System.Threading.Thread.Sleep(500);

        Response.Write(
            用于测试用类型.PageString
           );

        string str2 = "";
        string pubPage = "<title>赤壁——17173网络游戏专区——写于我们相识的第100天</title>";

        str2 = Regex.Match(pubPage, @"(?<=<title>)[^<>_\-\|\[&;]+", RegexOptions.IgnoreCase).Value;
        if (str2.Trim().Length < 2)
        {
            str2 = Regex.Match(pubPage, @"(?<=<title>)[^<>_\-]+", RegexOptions.IgnoreCase).Value;
        }
        if (str2.Trim().Length < 2)
        {
            str2 = Regex.Match(pubPage, "(?<=<title>)[^<>]+", RegexOptions.IgnoreCase).Value;
        }
        if (str2.Length > 200)
        {
            str2 = str2.Substring(0, 200);
        }

        Response.Write(str2);
    }
    /// 提取字符串可能相同部分的组合 
    /// </summary> 
    /// <param name="str1">源字符串</param> 
    /// <param name="str2">用于比较的字符串</param> 
    /// <returns>相同部分的字符串（数组）</returns> 
    private string[] Distill(string str1, string str2)
    {
        ArrayList al = new ArrayList();

        for (int index = 0; index < str2.Length; index++)
        {
            for (int length = 1; length <= str2.Length - index; length++)
            {
                string value = str2.Substring(index, length);
                if (str1.IndexOf(value) != -1)
                {
                    al.Add(value);
                }
            }
        }

        return (string[])al.ToArray(typeof(string));
    }
}

public class Get : PageTracksaction
{
    // Fields
    private Encoding CharsetCode = Encoding.Default;
    private int FingerNextPageUrlArray = 0;
    public ArrayList judgePageContentArray = new ArrayList();
    private ExtractPageMainContent MyEpm = new ExtractPageMainContent();
    private RegexMy MyReg = new RegexMy();
    private ArrayList NewsListPage = new ArrayList();
    public ArrayList NextPageArray = new ArrayList();
    public ArrayList NextPageUrlArray = new ArrayList();
    public string PageContent = "";

    // Methods
    public string GetNewsNextPage(string PubContent, string PubNewsUrl, string PageListUrl)
    {
        this.NewsListPage.Clear();
        this.NewsListPage.Add(PubNewsUrl);
        this.NewsListPage = base.ArrayListJoin(this.NewsListPage, this.MyReg.RegexToArray(this.MyReg.UrlExtractPageNext, PubContent));
        if (this.NewsListPage.Count > 1)
        {
            string pubPage = "";
            string str2 = "";
            for (int i = 1; i < this.NewsListPage.Count; i++)
            {
                if (i < this.NewsListPage.Count)
                {
                    pubPage = this.GetPage(this.NewsListPage[i].ToString());
                    pubPage = base.UrlUtterlyTransaction(pubPage, PageListUrl);
                    this.NewsListPage = base.ArrayListJoin(this.NewsListPage, this.MyReg.UrlPageNext(PubNewsUrl, pubPage));
                    pubPage = base.DiscardATag(pubPage);
                    pubPage = base.DiscardHtml(pubPage).Replace("\f", "") + "\f";
                    str2 = str2 + pubPage;
                }
            }
            return str2;
        }
        return "";
    }

    public string GetNewsPage(ArrayList PubAL)
    {
        try
        {
            this.judgePageContentArray.Clear();
            string pubPage = "";
            if (PubAL.Count > 0)
            {
                if (PubAL.Count == 1)
                {
                    pubPage = this.GetPage(PubAL[0].ToString());
                    pubPage = base.UrlUtterlyTransaction(pubPage, PubAL[0].ToString());
                    this.judgePageContentArray = base.WaveTackNewsList(base.ALDiscardReapet(this.MyReg.RegexToArray(this.MyReg.GetHref, pubPage)));
                    this.judgePageContentArray = base.ALDiscardReapet(this.judgePageContentArray);
                    return base.ArrayToBody(this.judgePageContentArray);
                }
                for (int i = 0; i < PubAL.Count; i++)
                {
                    pubPage = this.GetPage(PubAL[i].ToString());
                    pubPage = base.UrlUtterlyTransaction(pubPage, PubAL[i].ToString());
                    if (i == 0)
                    {
                        this.MyEpm.SourcePageDownArray = base.ALDiscardReapet(this.MyReg.RegexToArray(this.MyReg.GetHref, pubPage));
                    }
                    else if (i == (PubAL.Count - 1))
                    {
                        this.MyEpm.SourcePageUpArray = base.ALDiscardReapet(this.MyReg.RegexToArray(this.MyReg.GetHref, pubPage));
                        this.MyEpm.ExtractPageUrl();
                        this.judgePageContentArray = base.ArrayListJoin(this.judgePageContentArray, this.MyEpm.JudgePageUrlArray);
                        this.MyEpm.SourcePageUpArray = this.MyEpm.SourcePageDownArray;
                        this.MyEpm.SourcePageDownArray = base.ALDiscardReapet(this.MyReg.RegexToArray(this.MyReg.GetHref, pubPage));
                        this.MyEpm.ExtractPageUrl();
                        this.judgePageContentArray = base.ArrayListJoin(this.judgePageContentArray, this.MyEpm.JudgePageUrlArray);
                    }
                    else
                    {
                        this.MyEpm.SourcePageUpArray = base.ALDiscardReapet(this.MyReg.RegexToArray(this.MyReg.GetHref, pubPage));
                        this.MyEpm.ExtractPageUrl();
                        this.judgePageContentArray = base.ArrayListJoin(this.judgePageContentArray, this.MyEpm.JudgePageUrlArray);
                    }
                }
                this.judgePageContentArray = base.ArrayListDiscardRepeatTwo(this.judgePageContentArray, PubAL);
                return base.ArrayToBody(this.judgePageContentArray);
            }
            return "";
        }
        catch
        {
            return "<!--出错了：在 GetNewsPage 类中 -->";
        }
    }

    public string GetNextPage(string ListUrl)
    {
        RegexMy my = new RegexMy();
        PageTracksaction tracksaction = new PageTracksaction();
        this.PageContent = "";
        this.NextPageArray.Clear();
        this.NextPageUrlArray.Clear();
        this.NextPageUrlArray.Add(ListUrl);
        this.FingerNextPageUrlArray = 0;
        this.judgePageContentArray.Clear();
        base.ReplaceContentMode = false;
        this.PageContent = this.GetPage(ListUrl);
        this.PageContent = base.UrlUtterlyTransaction(this.PageContent, ListUrl);
        if (this.PageContent.Length > 200)
        {
            this.MyEpm.SourcePageDownArray = base.ALDiscardReapet(my.RegexToArray(my.GetHref, this.PageContent));
            this.NextPageUrlArray = tracksaction.ArrayListJoin(this.NextPageUrlArray, my.UrlPageNext(ListUrl, this.PageContent));
            this.NextPageUrlArray = tracksaction.ArrayListJoin(this.NextPageUrlArray, my.RegexToArray(my.UrlExtractPageNext, this.PageContent));
            if (this.NextPageUrlArray.Count > 1)
            {
                this.FingerNextPageUrlArray++;
                this.GetNextPageChild(this.NextPageUrlArray[this.FingerNextPageUrlArray].ToString());
            }
            else
            {
                //this.judgePageContentArray = base.WaveTackNewsList(this.MyEpm.SourcePageDownArray);

                //    this.objForm.SetTxtSortList = base.ArrayToBody(this.NextPageUrlArray);
                //    this.objForm.SetTxtNewsList = base.ArrayToBody(this.judgePageContentArray);
                //    this.objForm.SetLblCurrent = "当前处理：" + this.NextPageUrlArray[this.FingerNextPageUrlArray].ToString();
                //    this.objForm.SetProgressBar1 = Convert.ToInt32((double) ((Convert.ToDouble((int) (this.FingerNextPageUrlArray + 1)) / ((double) this.NextPageUrlArray.Count)) * 100.0));
         
            }
        }

            //this.objForm.SetTxtSortList = base.ArrayToBody(this.NextPageUrlArray);
            //this.objForm.SetTxtNewsList = base.ArrayToBody(this.judgePageContentArray);
      
        this.FingerNextPageUrlArray = 0;
        return base.ArrayToBody(this.NextPageUrlArray);
    }

    private void GetNextPageChild(string PubUrl)
    {
        string page = this.GetPage(PubUrl);
        page = base.UrlUtterlyTransaction(page, PubUrl);
        if (page.Length > 300)
        {
            int num;
            this.MyEpm.SourcePageUpArray = base.ALDiscardReapet(this.MyReg.RegexToArray(this.MyReg.GetHref, page));
            this.MyEpm.ExtractPageUrl();
            this.judgePageContentArray = base.ArrayListJoin(this.judgePageContentArray, this.MyEpm.JudgePageUrlArray);
            ArrayList list = this.MyReg.RegexToArray(this.MyReg.UrlExtractPageNext, page);
            if (list.Count > 0)
            {
                for (num = 0; num < list.Count; num++)
                {
                    if (!base.UrlRepeatJerqueFromArray(this.NextPageUrlArray, list[num].ToString()) && (list[num].ToString().Length > 5))
                    {
                        if (Regex.Match(this.NextPageUrlArray[this.NextPageUrlArray.Count - 1].ToString(), @"\/[^\/]+$").Value.ToString().IndexOf(".") != -1)
                        {
                            if (base.WaveTackNewsListDiffrence(this.NextPageUrlArray[this.NextPageUrlArray.Count - 1].ToString().Length, list[num].ToString().Length) < 3)
                            {
                                this.NextPageUrlArray.Add(list[num].ToString());
                            }
                        }
                        else
                        {
                            this.NextPageUrlArray.Add(list[num].ToString());
                        }
                    }
                }
            }
            list = this.MyReg.UrlPageNext(PubUrl, page);
            if (list.Count > 0)
            {
                for (num = 0; num < list.Count; num++)
                {
                    if (!base.UrlRepeatJerqueFromArray(this.NextPageUrlArray, list[num].ToString()) && (list[num].ToString().Length > 5))
                    {
                        this.NextPageUrlArray.Add(list[num].ToString());
                    }
                }
            }
            if (this.FingerNextPageUrlArray == (this.NextPageUrlArray.Count - 1))
            {
                ArrayList sourcePageUpArray = this.MyEpm.SourcePageUpArray;
                this.MyEpm.SourcePageUpArray = this.MyEpm.SourcePageDownArray;
                this.MyEpm.SourcePageDownArray = sourcePageUpArray;
                this.MyEpm.ExtractPageUrl();
                this.judgePageContentArray = base.ArrayListJoin(this.judgePageContentArray, this.MyEpm.JudgePageUrlArray);
            }
        }

            //this.objForm.SetTxtSortList = base.ArrayToBody(this.NextPageUrlArray);
            //this.objForm.SetTxtNewsList = base.ArrayToBody(this.judgePageContentArray);
            //this.objForm.SetLblCurrent = "当前处理：" + this.NextPageUrlArray[this.FingerNextPageUrlArray].ToString();
            //this.objForm.SetProgressBar1 = Convert.ToInt32((double) ((Convert.ToDouble((int) (this.FingerNextPageUrlArray + 1)) / ((double) this.NextPageUrlArray.Count)) * 100.0));

        this.FingerNextPageUrlArray++;
        this.NextPageUrlArray = base.ALDiscardReapet(this.NextPageUrlArray);
        if ((this.FingerNextPageUrlArray < this.NextPageUrlArray.Count) && (this.FingerNextPageUrlArray < 50))
        {
            this.GetNextPageChild(this.NextPageUrlArray[this.FingerNextPageUrlArray].ToString());
        }
    }

    public string GetPage(string PageUrl)
    {
        try
        {
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(PageUrl);
            HttpWebResponse response = (HttpWebResponse) request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream(), this.CharsetCode);
            string input = reader.ReadToEnd();
            string str2 = Regex.Match(input, @"^[\W\w]+?<title>", RegexOptions.IgnoreCase).Value.ToString();
            if (Regex.IsMatch(input, "charset=['\"]?UTF-8", RegexOptions.IgnoreCase) || Regex.IsMatch(input, "charset=['\"]?gb2312", RegexOptions.IgnoreCase))
            {
                if (Regex.IsMatch(str2, "charset=['\"]?UTF-8", RegexOptions.IgnoreCase) && (this.CharsetCode == Encoding.Default))
                {
                    this.CharsetCode = Encoding.UTF8;
                    return this.GetPage(PageUrl);
                }
                if (Regex.IsMatch(str2, "charset=['\"]?gb2312", RegexOptions.IgnoreCase) && (this.CharsetCode == Encoding.UTF8))
                {
                    this.CharsetCode = Encoding.Default;
                    return this.GetPage(PageUrl);
                }
            }
            else
            {
                this.CharsetCode = Encoding.Default;
            }
            response.Close();
            reader.Close();
            return Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(input, @"<script[^<>]*>[\w\W]*?</script>", "", RegexOptions.IgnoreCase), @"<style[^<>]*>[\w\W]*?</style>", "", RegexOptions.IgnoreCase), @"<object[^<>]*>[\w\W]*?</object>", "", RegexOptions.IgnoreCase), @"<iframe[^<>]*>[\w\W]*?</iframe>", "", RegexOptions.IgnoreCase), @"\s{5,20}", "", RegexOptions.IgnoreCase), "alt=['\"]?[^'\"\\s]?['\"]?", "", RegexOptions.IgnoreCase), @"(<U>)|(<\/U>)", "", RegexOptions.IgnoreCase), "onload=['\"]?[^'\"\\s]+?['\"]?", "", RegexOptions.IgnoreCase).Replace("'", "\""), "&nbsp;&nbsp;", "　", RegexOptions.IgnoreCase), "&nbsp;", "　", RegexOptions.IgnoreCase);
        }
        catch
        {
            return "404";
        }
    }

    public bool ImgSave(string PubImageUrl, string DirectoryName)
    {
        bool flag2;
        bool flag = false;
        Bitmap bitmap = null;
        HttpWebResponse response = null;
        try
        {
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(PubImageUrl);
            response = (HttpWebResponse) request.GetResponse();
            bitmap = new Bitmap(response.GetResponseStream());
            if ((bitmap.Height > 50) || (bitmap.Width > 50))
            {
                bitmap.Save(base.DirCreateExist(DirectoryName) + "/" + base.UrlToFileName(PubImageUrl));
                flag = true;
            }
            bitmap.Dispose();
            response.Close();
            flag2 = flag;
        }
        catch
        {
            flag2 = flag;
        }
        finally
        {
            if (response != null)
            {
                response.Close();
            }
        }
        return flag2;
    }
}







public class MultiPageAutoGet
{
    private bool dateDown = false;
    private bool dateUp = false;
    private int GatherRepeat = 0;
    private int InputForm_ = 0;
    //private delegateMy MyDelegate = new delegateMy();
    private ArrayList NewsListPage = new ArrayList();
 //   private FrmNewsGather objForm;
    private string PageDown = "";
    private string PageListUrl = "";
    private string PageUp = "";
    private string ReplaceSource = "";
    private string ReplaceTarget = "";
    private string SetTxtNewsList_;
    private int sid = 0;
    private ArrayList ThAl = new ArrayList();
    private ArrayList txtNewsArray = new ArrayList();

    /// <summary>
    /// 用于保存页面的字符串
    /// </summary>
    public string PageString = "";

    private string ArrayListSplit(int PubBegin, int PubEnd)
    {
        Get get = new Get();
        ArrayList pubContent = new ArrayList();
        for (int i = PubBegin; i < (PubEnd + 1); i++)
        {
            if (i < this.txtNewsArray.Count)
            {
                pubContent.Add(this.txtNewsArray[i].ToString());
            }
        }
        return get.ArrayToBody(pubContent);
    }

    private void GatherAll()
    {
        Get get = new Get();
        RegexMy my = new RegexMy();
   //     SiteOledb oledb = new SiteOledb();
        ArrayList list = my.RegexToArray(@"[^\r\n]+", this.ThAl[Convert.ToInt16(Thread.CurrentThread.Name)].ToString());
        string pubPage = "";
        string str2 = "";
        for (int i = 0; i < list.Count; i++)
        {
            pubPage = get.GetPage(list[i].ToString());
            pubPage = get.UrlUtterlyTransaction(pubPage, list[i].ToString());
            str2 = Regex.Match(pubPage, @"(?<=<title>)[^<>_\-\|\[&;]+", RegexOptions.IgnoreCase).Value;
            if (str2.Trim().Length < 2)
            {
                str2 = Regex.Match(pubPage, @"(?<=<title>)[^<>_\-]+", RegexOptions.IgnoreCase).Value;
            }
            if (str2.Trim().Length < 2)
            {
                str2 = Regex.Match(pubPage, "(?<=<title>)[^<>]+", RegexOptions.IgnoreCase).Value;
            }
            if (str2.Length > 200)
            {
                str2 = str2.Substring(0, 200);
            }
            this.NewsListPage.Clear();
            this.NewsListPage.Add(list[i].ToString());
            this.NewsListPage = get.ArrayListJoin(this.NewsListPage, my.UrlPageNext(list[i].ToString(), pubPage));
            this.NewsListPage = get.ArrayListJoin(this.NewsListPage, my.RegexToArray(my.UrlExtractPageNext, pubPage));
            pubPage = get.DiscardATag(pubPage);
            pubPage = get.DiscardHtml(pubPage);
            pubPage = this.PageUpDownAndReplace(pubPage).Replace("\f", "") + "\f";
            lock (this.NewsListPage)
            {
                pubPage = pubPage + this.GetNewsNextPage(list[i].ToString());
            }
            //if (!oledb.SqlExists("select id from Content where Title = '" + str2 + "'"))
            //{
            //    goto Label_04C2;
            //}



            PageString += pubPage+"<br/>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br/>";

            switch (this.GatherRepeat)
            {
                case 0:
                    switch (this.InputForm_)
                    {
                        case 2:
                            goto Label_05BC;
                    }
                    goto Label_05BC;

                case 1:
                    //oledb.ExecuteSql(string.Concat(new object[] { "update Content Set sid= ", this.sid, ", url = '", list[i].ToString().Trim().Replace("'", ""), "',content='", pubPage.Replace("'", ""), "',title='", str2, "',ListUrl = '", this.PageListUrl, "' where title='", str2, "'" }));
                    switch (this.InputForm_)
                    {
                        case 1:
                            goto Label_035A;

                        case 2:
                            goto Label_05BC;
                    }
                    goto Label_05BC;

                case 2:
                    //oledb.ExecuteSql(string.Concat(new object[] { "insert into Content(sid,Url,content,title,ListUrl) values( ", this.sid, ",'", list[i].ToString().Trim().Replace("'", ""), "','", pubPage.Replace("'", ""), "','", str2, "','", this.PageListUrl, "')" }));
                    switch (this.InputForm_)
                    {
                        case 1:
                            goto Label_044B;

                        case 2:
                            goto Label_05BC;
                    }
                    goto Label_05BC;

                default:
                    goto Label_0476;
            }
            this.SetTxtNewsList_ = this.SetTxtNewsList_.Replace(list[i].ToString(), "数据已经存在，已跳过");
            goto Label_05BC;
        Label_035A:
            this.SetTxtNewsList_ = this.SetTxtNewsList_.Replace(list[i].ToString(), "数据已经存在，已替换");
            goto Label_05BC;
        Label_044B:
            this.SetTxtNewsList_ = this.SetTxtNewsList_.Replace(list[i].ToString(), "数据已经存在，已忽略,成功入库");
            goto Label_05BC;
        Label_0476:
            switch (this.InputForm_)
            {
                case 1:
                    this.SetTxtNewsList_ = this.SetTxtNewsList_.Replace(list[i].ToString(), "数据已经存在，已跳过");
                    goto Label_05BC;

                default:
                    goto Label_05BC;
            }
        Label_04C2: ;
            //oledb.ExecuteSql(string.Concat(new object[] { "insert into Content(sid,Url,content,title,ListUrl) values( ", this.sid, ", '", list[i].ToString().Trim().Replace("'", ""), "','", pubPage.Replace("'", ""), "','", str2, "','", this.PageListUrl, "')" }));
            switch (this.InputForm_)
            {
                case 1:
                    this.SetTxtNewsList_ = this.SetTxtNewsList_.Replace(list[i].ToString(), "成功入库");
                    break;
            }
            this.NewsListPage.Clear();
        Label_05BC:
            switch (this.InputForm_)
            {
                case 1:
                    //this.objForm.SetProgressBar1 = Convert.ToInt32((double)((Convert.ToDouble((int)(i + 1)) / Convert.ToDouble(list.Count)) * 100.0));
                    //this.objForm.SetTxtNewsList = this.SetTxtNewsList_;
                    //this.objForm.SetLblCurrent = list[i].ToString();


                    break;
            }


        }
    }

    public void GetMain(int InputForm, ArrayList GAal, string PageListUrl_, int ThreadCount, int GatherRepeat_)
    {
        int num3;
        Get get = new Get();
        RegexMy my = new RegexMy();
        this.GatherRepeat = GatherRepeat_;
        this.PageListUrl = PageListUrl_;
        this.InputForm_ = InputForm;
       // DataTable table = this.MyDb.dataTable("select * from PageList where Url='" + this.PageListUrl + "'");
        //if (table.Rows.Count > 0)
        //{
        //    //this.PageUp = table.Rows[0]["RuleUp"].ToString();
        //    //this.PageDown = table.Rows[0]["RuleDown"].ToString();
        //    //this.ReplaceSource = table.Rows[0]["ReplaceSource"].ToString();
        //    //this.ReplaceTarget = table.Rows[0]["ReplaceTarget"].ToString();
        //    //if (table.Rows[0]["RuleUpDate"].ToString() == "1")
        //    //{
        //    //    this.dateUp = true;
        //    //}
        //    //else
        //    //{
        //    //    this.dateUp = false;
        //    //}
        //    //if (table.Rows[0]["RuleDownDate"].ToString() == "1")
        //    //{
        //    //    this.dateDown = true;
        //    //}
        //    //else
        //    //{
        //    //    this.dateDown = false;
        //    //}
        //}
        //else
        //{
        //    this.PageUp = "";
        //    this.PageDown = "";
        //    this.ReplaceSource = "";
        //    this.ReplaceTarget = "";
        //}
        this.txtNewsArray = GAal;
        int count = ThreadCount;
        if (count == 0)
        {
            count = 10;
        }
        if (GAal.Count > 5)
        {
            if (count > 20)
            {
                count = 20;
            }
            if (GAal.Count < count)
            {
                count = GAal.Count;
            }
        }
        else
        {
            count = 1;
        }
        int pubEnd = this.txtNewsArray.Count / count;
        this.SetTxtNewsList_ = get.ArrayToBody(GAal);
        //DataTable table2 = new DataTable();
        //table2 = this.MyDb.dataTable("select * from PageList where Url='" + this.PageListUrl + "'");
        //if (table2.Rows.Count > 0)
        //{
        //    this.sid = Convert.ToInt16(table2.Rows[0]["id"]);
        //}
        for (num3 = 0; num3 < count; num3++)
        {
            if (num3 == (count - 1))
            {
                this.ThAl.Add(this.ArrayListSplit(num3 * pubEnd, this.txtNewsArray.Count));
            }
            else if (num3 == 0)
            {
                this.ThAl.Add(this.ArrayListSplit(0, pubEnd));
            }
            else
            {
                this.ThAl.Add(this.ArrayListSplit(num3 * pubEnd, ((num3 * pubEnd) + pubEnd) - 1));
            }
        }
        for (num3 = 0; num3 < count; num3++)
        {
            Thread thread = new Thread(new ThreadStart(this.GatherAll));
            thread.Name = num3.ToString();
            thread.Start();
        }
    }

    //public void GetMain(int InputForm, ArrayList GAal, string PageListUrl_, int ThreadCount, int GatherRepeat_, FrmNewsGather objForm_)
    //{
    //    int num3;
    //    Get get = new Get();
    //    RegexMy my = new RegexMy();
    //    this.GatherRepeat = GatherRepeat_;
    //    this.objForm = objForm_;
    //    this.PageListUrl = PageListUrl_;
    //    this.InputForm_ = InputForm;
    //    DataTable table = this.MyDb.dataTable("select * from PageList where Url='" + this.PageListUrl + "'");
    //    if (table.Rows.Count > 0)
    //    {
    //        this.PageUp = table.Rows[0]["RuleUp"].ToString();
    //        this.PageDown = table.Rows[0]["RuleDown"].ToString();
    //        this.ReplaceSource = table.Rows[0]["ReplaceSource"].ToString();
    //        this.ReplaceTarget = table.Rows[0]["ReplaceTarget"].ToString();
    //        if (table.Rows[0]["RuleUpDate"].ToString() == "1")
    //        {
    //            this.dateUp = true;
    //        }
    //        else
    //        {
    //            this.dateUp = false;
    //        }
    //        if (table.Rows[0]["RuleDownDate"].ToString() == "1")
    //        {
    //            this.dateDown = true;
    //        }
    //        else
    //        {
    //            this.dateDown = false;
    //        }
    //    }
    //    else
    //    {
    //        this.PageUp = "";
    //        this.PageDown = "";
    //        this.ReplaceSource = "";
    //        this.ReplaceTarget = "";
    //    }
    //    this.txtNewsArray = GAal;
    //    int count = ThreadCount;
    //    if (count == 0)
    //    {
    //        count = 10;
    //    }
    //    if (GAal.Count > 5)
    //    {
    //        if (count > 20)
    //        {
    //            count = 20;
    //        }
    //        if (GAal.Count < count)
    //        {
    //            count = GAal.Count;
    //        }
    //    }
    //    else
    //    {
    //        count = 1;
    //    }
    //    int pubEnd = this.txtNewsArray.Count / count;
    //    this.SetTxtNewsList_ = get.ArrayToBody(GAal);
    //    DataTable table2 = new DataTable();
    //    table2 = this.MyDb.dataTable("select * from PageList where Url='" + this.PageListUrl + "'");
    //    if (table2.Rows.Count > 0)
    //    {
    //        this.sid = Convert.ToInt16(table2.Rows[0]["id"]);
    //    }
    //    for (num3 = 0; num3 < count; num3++)
    //    {
    //        if (num3 == (count - 1))
    //        {
    //            this.ThAl.Add(this.ArrayListSplit(num3 * pubEnd, this.txtNewsArray.Count));
    //        }
    //        else if (num3 == 0)
    //        {
    //            this.ThAl.Add(this.ArrayListSplit(0, pubEnd));
    //        }
    //        else
    //        {
    //            this.ThAl.Add(this.ArrayListSplit(num3 * pubEnd, ((num3 * pubEnd) + pubEnd) - 1));
    //        }
    //    }
    //    for (num3 = 0; num3 < count; num3++)
    //    {
    //        Thread thread = new Thread(new ThreadStart(this.GatherAll));
    //        thread.Name = num3.ToString();
    //        thread.Start();
    //    }
    //}

    private string GetNewsNextPage(string PubNewsUrl)
    {
        Get get = new Get();
        RegexMy my = new RegexMy();
        if (this.NewsListPage.Count > 1)
        {
            string pubPage = "";
            string str2 = "";
            for (int i = 1; i < this.NewsListPage.Count; i++)
            {
                if (i < this.NewsListPage.Count)
                {
                    pubPage = get.GetPage(this.NewsListPage[i].ToString());
                    pubPage = get.UrlUtterlyTransaction(pubPage, this.PageListUrl);
                    this.NewsListPage = get.ArrayListJoin(this.NewsListPage, my.UrlPageNext(PubNewsUrl, pubPage));
                    this.NewsListPage = get.ArrayListJoin(this.NewsListPage, my.RegexToArray(my.UrlExtractPageNext, pubPage));
                    pubPage = get.DiscardATag(pubPage);
                    pubPage = get.DiscardHtml(pubPage);
                    pubPage = this.PageUpDownAndReplace(pubPage).Replace("\f", "") + "\f";
                    str2 = str2 + pubPage;
                }
            }
            return str2;
        }
        return "";
    }

    private string PageUpDownAndReplace(string PubContent)
    {
        Get get = new Get();
        RegexMy my = new RegexMy();
        if (this.dateUp)
        {
            PubContent = my.DateExtractPageContent(PubContent, "up");
        }
        if (this.dateDown)
        {
            PubContent = my.DateExtractPageContent(PubContent, "down");
        }
        if ((this.PageUp.Length > 0) && (PubContent.IndexOf(this.PageUp) != -1))
        {
            PubContent = PubContent.Substring(PubContent.IndexOf(this.PageUp));
        }
        if ((this.PageDown.Length > 0) && (PubContent.LastIndexOf(this.PageDown) != -1))
        {
            PubContent = PubContent.Substring(0, PubContent.LastIndexOf(this.PageDown));
        }
        if (this.ReplaceSource.Length > 0)
        {
            PubContent = PubContent.Replace(this.ReplaceSource, this.ReplaceTarget);
        }
        return PubContent;
    }
}

public class PageTracksaction : ExtractPageMainContent
    {
        public ArrayList ALDiscardReapet(ArrayList PubAL)
        {
            ArrayList pubAL = new ArrayList();
            if (PubAL.Count > 0)
            {
                for (int i = 0; i < PubAL.Count; i++)
                {
                    if (!this.UrlRepeatJerqueFromArray(pubAL, PubAL[i].ToString()))
                    {
                        pubAL.Add(PubAL[i].ToString());
                    }
                }
            }
            return pubAL;
        }

        public string ALDiscardReapetToStr(ArrayList PubAL)
        {
            string str = "";
            if (PubAL.Count > 0)
            {
                for (int i = 0; i < PubAL.Count; i++)
                {
                    if (str.IndexOf(PubAL[i].ToString()) == -1)
                    {
                        str = str + PubAL[i].ToString() + "\r\n";
                    }
                }
            }
            return str;
        }

        public ArrayList ArrayListDiscardRepeatTwo(ArrayList al1, ArrayList al2)
        {
            ArrayList list = new ArrayList();
            if ((al1.Count > 0) && (al2.Count > 0))
            {
                for (int i = 0; i < al1.Count; i++)
                {
                    if (!this.UrlRepeatJerqueFromArray(al2, al1[i].ToString()))
                    {
                        list.Add(al1[i].ToString());
                    }
                }
                return list;
            }
            return al1;
        }

        public ArrayList ArrayListJoin(ArrayList al1, ArrayList al2)
        {
            if (al2.Count > 0)
            {
                for (int i = 0; i < al2.Count; i++)
                {
                    if (!((al2[i].ToString().Trim().Length <= 1) || this.UrlRepeatJerqueFromArray(al1, al2[i].ToString().Trim())))
                    {
                        al1.Add(al2[i].ToString());
                    }
                }
            }
            return al1;
        }

        public string ArrayToBody(ArrayList PubContent)
        {
            string str = "";
            for (int i = 0; i < PubContent.Count; i++)
            {
                str = str + PubContent[i].ToString() + "\r\n";
            }
            return str;
        }

        public string DirCreateExist(string DirectoryName)
        {
            if (!Directory.Exists(Environment.CurrentDirectory.ToString() + @"\" + DirectoryName))
            {
                Directory.CreateDirectory(Environment.CurrentDirectory.ToString() + @"\" + DirectoryName);
            }
            return (Environment.CurrentDirectory.ToString() + @"\" + DirectoryName);
        }

        public string PageNextDiscardList(ArrayList PubAL, string PubContent)
        {
            if (PubAL.Count > 0)
            {
                for (int i = 0; i < PubAL.Count; i++)
                {
                    PubContent = PubContent.Replace(PubAL[i].ToString() + "\r\n", "");
                }
            }
            return PubContent;
        }

        private string UrlColumnDir(string PubUrl)
        {
            if (Regex.IsMatch(PubUrl, @"\/$"))
            {
                return PubUrl;
            }
            if (Regex.IsMatch(PubUrl, @"\/[^\.<>\/\\]+\.[^\.<>\/\\]+$"))
            {
                return Regex.Replace(PubUrl, @"\/[^\.<>\/\\]+\.[^\.<>\/\\]+$", "/");
            }
            return (PubUrl + "/");
        }

        private string UrlDotDotWand(string PubUrl, int PubCount)
        {
            string str2;
            try
            {
                int num;
                string str = this.UrlColumnDir(PubUrl);
                switch (PubCount)
                {
                    case 1:
                        str = str.Substring(0, str.LastIndexOf("/") - 1);
                        goto Label_0091;

                    case 2:
                        num = 0;
                        goto Label_006C;

                    case 3:
                        num = 0;
                        goto Label_0041;

                    default:
                        goto Label_0091;
                }
            Label_0026:
                str = str.Substring(0, str.LastIndexOf("/") - 1);
                num++;
            Label_0041:
                if (num < 3)
                {
                    goto Label_0026;
                }
                goto Label_0091;
            Label_0051:
                str = str.Substring(0, str.LastIndexOf("/") - 1);
                num++;
            Label_006C:
                if (num < 2)
                {
                    goto Label_0051;
                }
            Label_0091:
                str2 = str.Substring(0, str.LastIndexOf("/") + 1);
            }
            catch
            {
                str2 = PubUrl;
            }
            return str2;
        }

        public bool UrlRepeatJerqueFromArray(ArrayList PubAL, string PubUrl)
        {
            for (int i = 0; i < PubAL.Count; i++)
            {
                if (PubAL[i].ToString() == PubUrl)
                {
                    return true;
                }
            }
            return false;
        }

        private string UrlSiteRootDir(string PubDomain)
        {
            string str = PubDomain.Replace("http://", "");
            if (str.IndexOf("/") > 0)
            {
                return ("http://" + str.Substring(0, str.IndexOf("/")) + "/");
            }
            return (PubDomain + "/");
        }

        public string UrlToFileName(string Url)
        {
            if (Url.Length > 0)
            {
                int num = Url.LastIndexOf("/");
                return Url.Substring(num + 1, (Url.Length - num) - 1);
            }
            return "这个没有文件名UrlToFileName";
        }

        public string UrlUtterlyTransaction(string PubPage, string PubUrl)
        {
            string pubUrl = this.UrlColumnDir(PubUrl);
            PubUrl = this.UrlSiteRootDir(PubUrl);
            PubPage = PubPage.Replace("../../../", this.UrlDotDotWand(pubUrl, 3));
            PubPage = PubPage.Replace("../../", this.UrlDotDotWand(pubUrl, 2));
            PubPage = PubPage.Replace("./../../", this.UrlDotDotWand(pubUrl, 2));
            PubPage = PubPage.Replace("./../", this.UrlDotDotWand(pubUrl, 1));
            PubPage = PubPage.Replace("../", this.UrlDotDotWand(pubUrl, 1));
            PubPage = Regex.Replace(PubPage, "href=/", "href=" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "href='/", "href='" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "href=\"/", "href=\"" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "href=\"(?=[^(http)])", "href=\"" + pubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "href='(?=[^(http)])", "href='" + pubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "href=(?=[^(http)'\"\\/])", "href=" + pubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "src=/", "src=" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "src='/", "src='" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "src=\"/", "src=\"" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "src=\"(?=[^(http)])", "src=\"" + pubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "src='(?=[^(http)])", "src='" + pubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "src=(?=[^(http)'\"\\/])", "src=" + pubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "<option value='/", "<option value='" + PubUrl, RegexOptions.IgnoreCase);
            PubPage = Regex.Replace(PubPage, "<option value=\"/", "<option value=\"" + PubUrl, RegexOptions.IgnoreCase);
            return PubPage;
        }

        public ArrayList WaveTackNewsList(ArrayList PubAL)
        {
            int num8;
            if (PubAL.Count <= 3)
            {
                return PubAL;
            }
            int num = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;
            int length = 0;
            int num7 = 0;
            for (num8 = 0; num8 < PubAL.Count; num8++)
            {
                if (num8 < (PubAL.Count - 1))
                {
                    length = PubAL[num8].ToString().Length;
                    num7 = PubAL[num8 + 1].ToString().Length;
                }
                else
                {
                    length = PubAL[num8 - 1].ToString().Length;
                    num7 = PubAL[num8].ToString().Length;
                }
                if (this.WaveTackNewsListDiffrence(length, num7) < 3)
                {
                    num5++;
                }
                else
                {
                    if (num5 > num3)
                    {
                        num3 = num5;
                        num2 = num8;
                        num = num4;
                    }
                    num5 = 0;
                    num4 = num8;
                }
                if (num5 > num3)
                {
                    num3 = num5;
                    num2 = num8;
                    num = num4;
                }
            }
            if (PubAL.Count == num3)
            {
                return PubAL;
            }
            ArrayList list = new ArrayList();
            if ((num2 + 1) < PubAL.Count)
            {
                for (num8 = num + 1; num8 < (num2 + 1); num8++)
                {
                    list.Add(PubAL[num8].ToString());
                }
                return list;
            }
            for (num8 = num; num8 < num2; num8++)
            {
                list.Add(PubAL[num8].ToString());
            }
            return list;
        }

        public int WaveTackNewsListDiffrence(int int1, int int2)
        {
            int num = 0;
            if (int1 < int2)
            {
                num = int1;
                int1 = int2;
                int2 = num;
            }
            return (int1 - int2);
        }
    }

    public class RegexMy
    {
        public string DateReg = @"(\d{2,4}-\d{1,2}-\d{1,2}(\s+)?(\d{1,2}:\d{1,2}:\d{1,2})?)|(\d{2,4}\s?年\s?\d{1,2}\s?月\s?\d{1,2}\s?日\s+?(\d{2,4}:\d{2,4})(:\d{2,4})?)";
        public string ExtractPageContent = @"([^\x00-\xff]){20,}";
        public string GetHref = "(?<=href=[\"'\\\\\\/\\w]?)[^\\s'\"\\r\\n<>]+";
        public string UrlExtractListPage = "(?<=href=[\"'\\\\\\/\\w]+)[^\\s<>'\"]+((((index)|(list)|(default))[_\\-]?\\d*\\.\\w{3,4}(\\?[^'\"<>\\s]+)?)|(\\/(?=['\"\\s<>]))|(\\/[^\\.<>\"'\\s]+)(?=['\"<>\\s]))";
        public string UrlExtractPageNext = "http:[^<>\\s\"']+(?=[^<>]*>\\s?((\\[?下一页\\]?)|([^'\"<>\\\\\\/首主]{0,2}页)|\\[?\\d\\]?|\\(?\\d\\)?)\\s?<)";

        public string DateExtractPageContent(string PubContent, string PubFlag)
        {
            if ((PubContent.Length > 0) && (PubFlag.Length > 0))
            {
                string str = "";
                if (PubFlag == "up")
                {
                    str = Regex.Match(PubContent, this.DateReg, RegexOptions.Multiline).Value.ToString();
                    if (str.Length > 6)
                    {
                        return PubContent.Substring(PubContent.IndexOf(str) + str.Length);
                    }
                    return PubContent;
                }
                if (str == "down")
                {
                    str = Regex.Match(PubContent, this.DateReg, RegexOptions.RightToLeft | RegexOptions.Multiline).Value.ToString();
                    if (str.Length > 6)
                    {
                        return PubContent.Substring(0, PubContent.LastIndexOf(str));
                    }
                }
            }
            return PubContent;
        }

        public ArrayList RegexToArray(string PubReg, string PageContent)
        {
            ArrayList list = new ArrayList();
            MatchCollection matchs = new Regex(PubReg, RegexOptions.IgnoreCase).Matches(PageContent);
            for (int i = 0; i < matchs.Count; i++)
            {
                list.Add(matchs[i].ToString());
            }
            return list;
        }

        public ArrayList UrlPageNext(string CurUrl, string Content)
        {
            string str = CurUrl.Substring(0, CurUrl.LastIndexOf("."));
            string str2 = CurUrl.Substring(CurUrl.LastIndexOf(".") + 1, (CurUrl.Length - CurUrl.LastIndexOf(".")) - 1);
            ArrayList list = new ArrayList();
            if (Content.Length >= 10)
            {
                MatchCollection matchs = new Regex(str + @"[_\-]?\d{1,2}\." + str2).Matches(Content);
                for (int i = 0; i < matchs.Count; i++)
                {
                    list.Add(matchs[i].ToString());
                }
            }
            return list;
        }
    }

    public class ExtractPageMainContent
    {
        private int AltCount = 0x1d;
        public int BInt = 0;
        public string ContrastContentChild = "";
        public int EInt = 0;
        private int FlagLength = 50;
        private string ImageSaveToDirChild = "";
        public string JudgePage = "";
        public ArrayList JudgePageUrlArray = new ArrayList();
        public int NewsRepeat = 0;
        public int Once = 0;
        public int Orientation = 0;
        public bool OrientationSwitch = false;
        public string PBegin = "";
        public int PBeginRepeat = 0;
        public string PEnd = "";
        public int PEndRepeat = 0;
        public int progressBar1CurrentValue = 0;
        public string RBegin = "";
        public string REnd = "";
        public string ReplaceContent = "";
        public bool ReplaceContentMode = false;
        public int Secuess = 0;
        public string SourcePageDown = "";
        public ArrayList SourcePageDownArray = new ArrayList();
        public string SourcePageUp = "";
        public ArrayList SourcePageUpArray = new ArrayList();
        private ArrayList UrlNextPageAl = new ArrayList();

        private void Advertisement()
        {
            RegexMy my = new RegexMy();
            string str = this.ContrastContentChild.Substring(0, this.BInt);
            bool flag = false;
            int num = 0;
            int num2 = 0;
            for (int i = 3; i < str.Length; i++)
            {
                if ((i >= str.Length) || (i >= 160))
                {
                    break;
                }
                if (!(!(str.Substring(str.Length - i, 1) == "0") || flag))
                {
                    flag = true;
                    num2 = str.Length - i;
                }
                if ((str.Substring(str.Length - i, 1) == "1") && flag)
                {
                    num = str.Length - i;
                    if (Regex.IsMatch(this.SourcePageUp.Substring((this.AltCount + 1) * num, ((this.AltCount + 2) * num2) - ((this.AltCount + 1) * num)), my.ExtractPageContent))
                    {
                        int pubBegin = (this.AltCount + 1) * (num2 + 1);
                        int pubEnd = ((this.AltCount + 1) * (this.BInt - 1)) - ((this.AltCount + 1) * (num2 + 1));
                        this.ReplaceBlock(pubBegin, pubEnd);
                        break;
                    }
                }
            }
        }

        private void BeginEnd()
        {
            string contrastContentChild = this.ContrastContentChild;
            int num = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;
            bool flag = false;
            string str2 = "1";
            for (int i = 0; i < contrastContentChild.Length; i++)
            {
                if (contrastContentChild.Substring(i, 1) == "0")
                {
                    if (str2 == "0")
                    {
                        num5++;
                    }
                    if (num5 == 0)
                    {
                        num4 = i;
                    }
                    int num7 = ((this.AltCount + 1) * i) - this.Orientation;
                    if ((num7 > 0) && (num7 < ((this.AltCount + 1) * 5)))
                    {
                        flag = true;
                    }
                }
                else
                {
                    if (num5 > num3)
                    {
                        num3 = num5;
                        num = num4;
                        num2 = i;
                    }
                    num5 = 0;
                    if (flag && (this.Orientation > 10))
                    {
                        this.BInt = num4;
                        this.EInt = i;
                        break;
                    }
                    flag = false;
                }
                str2 = contrastContentChild.Substring(i, 1);
            }
            this.BInt = num;
            this.EInt = num2;
        }

        private void ContrastContent()
        {
            if ((this.PBegin.Length < 5) || (this.PEnd.Length < 5))
            {
                int num;
                this.ContrastContentChild = "";
                this.SourcePageUp = Regex.Replace(this.SourcePageUp, @"<a\s+[^<>]+>", "", RegexOptions.IgnoreCase);
                this.SourcePageDown = Regex.Replace(this.SourcePageDown, @"<a\s+[^<>]+>", "", RegexOptions.IgnoreCase);
                this.SourcePageUp = Regex.Replace(this.SourcePageUp, @"<\/a>", "", RegexOptions.IgnoreCase);
                this.SourcePageDown = Regex.Replace(this.SourcePageDown, @"<\/a>", "", RegexOptions.IgnoreCase);
                string str = "";
                for (num = 0; num < (this.SourcePageUp.Length - this.FlagLength); num++)
                {
                    str = this.SourcePageUp.Substring(num, this.FlagLength);
                    if (this.SourcePageDown.IndexOf(str) == -1)
                    {
                        this.ContrastContentChild = this.ContrastContentChild + "0";
                    }
                    else
                    {
                        this.ContrastContentChild = this.ContrastContentChild + "1";
                    }
                    num += this.AltCount;
                }
                if (this.OrientationSwitch)
                {
                    string[] strArray = new string[] { "导读" };
                    for (num = 0; num < strArray.Length; num++)
                    {
                        if (this.SourcePageUp.IndexOf(strArray[num]) != -1)
                        {
                            this.OrientationGoTo();
                        }
                    }
                }
                this.BeginEnd();
                if ((this.BInt > 4) && (this.EInt > 10))
                {
                    if (this.PBegin.Length < 5)
                    {
                        str = this.SourcePageUp.Substring((this.AltCount + 1) * (this.BInt - 1), this.AltCount + 1);
                        if (this.PBegin.Length < 5)
                        {
                            this.PBegin = str;
                            for (num = 0; num < this.AltCount; num++)
                            {
                                str = this.SourcePageUp.Substring((this.AltCount + 1) * (this.BInt - 1), (this.AltCount + 1) + num);
                                if (this.SourcePageDown.IndexOf(str) != -1)
                                {
                                    this.PBegin = str;
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (this.PEnd.Length < 5)
                    {
                        str = this.SourcePageUp.Substring((this.AltCount + 1) * this.EInt, this.AltCount + 1);
                        if (this.PEnd.Length < 5)
                        {
                            this.PEnd = str;
                            for (num = 0; num < this.AltCount; num++)
                            {
                                str = this.SourcePageUp.Substring(((this.AltCount + 1) * this.EInt) - num, (this.AltCount + 1) + num);
                                if (this.SourcePageDown.IndexOf(str) != -1)
                                {
                                    this.PEnd = str;
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }

        public string DiscardATag(string PageContent)
        {
            PageContent = Regex.Replace(PageContent, @"<a\s+[^<>]+>", "", RegexOptions.IgnoreCase);
            PageContent = Regex.Replace(PageContent, @"<\/a>", "", RegexOptions.IgnoreCase);
            return PageContent;
        }

        public string DiscardHtml(string GetContent)
        {
            GetContent = Regex.Replace(GetContent, "<strong>", "<b>", RegexOptions.IgnoreCase);
            GetContent = Regex.Replace(GetContent, @"<\/strong>", "</b>", RegexOptions.IgnoreCase);
            GetContent = Regex.Replace(GetContent, @"(<iframe[^<>]+>)|(<\/iframe>)", "", RegexOptions.IgnoreCase);
            GetContent = Regex.Replace(GetContent, "&nbsp;&nbsp;", "　");
            GetContent = Regex.Replace(GetContent, "&nbsp;", "　");
            GetContent = Regex.Replace(GetContent, @"(<[^ibp\/][^<>]+>)|(<\/[^bp][^<>]*>)", "", RegexOptions.IgnoreCase);
            GetContent = Regex.Replace(GetContent, "(onload=['\"][^<>'\"]+['\"])|(style=['\"][^'\"<>]+['\"])|(onclick=['\"][^<>'\"]+['\"])", "", RegexOptions.IgnoreCase);
            GetContent = Regex.Replace(GetContent, "onload=['\"][^'\"]+\\s", "", RegexOptions.IgnoreCase);
            return GetContent;
        }

        public void ExtractPageContent()
        {
            this.JudgePage = "";
            this.ContrastContent();
            this.JudgePage = this.SourcePageUp;
            if (((this.BInt > 5) && (this.EInt > 10)) && (this.EInt > this.BInt))
            {
                if (this.JudgePage.IndexOf(this.PBegin) == -1)
                {
                    this.PBegin = "";
                    this.ContrastContent();
                }
                if (this.JudgePage.IndexOf(this.PEnd) == -1)
                {
                    this.PEnd = "";
                    this.ContrastContent();
                }
                if ((this.JudgePage.IndexOf(this.PBegin) == -1) || (this.JudgePage.IndexOf(this.PEnd) == -1))
                {
                    this.Secuess = 0;
                    this.JudgePage = "<!--出错啦！！ 模块：Gather:[171]" + this.PBegin + "|||" + this.PEnd + "|||-->" + this.JudgePage;
                    if (this.JudgePage.IndexOf(this.PBegin) == -1)
                    {
                        this.PBeginRepeat = 0;
                    }
                    else if (this.JudgePage.IndexOf(this.PEnd) == -1)
                    {
                        this.PEndRepeat = 0;
                    }
                }
                else
                {
                    try
                    {
                        int index = this.JudgePage.IndexOf(this.PBegin);
                        this.JudgePage = this.JudgePage.Substring(index + this.PBegin.Length, this.JudgePage.Length - (index + this.PBegin.Length));
                        int length = this.JudgePage.IndexOf(this.PEnd);
                        this.JudgePage = this.JudgePage.Substring(0, length);
                        this.Secuess = 1;
                        this.PBeginRepeat++;
                        this.PEndRepeat++;
                    }
                    catch
                    {
                        this.Secuess = 2;
                        this.JudgePage = "<!--出错啦！！try Catch 模块：Gather:[184]" + this.PBegin + "|||" + this.PEnd + "|||-->" + this.JudgePage;
                    }
                }
            }
        }

        public void ExtractPageUrl()
        {
            PageTracksaction tracksaction = new PageTracksaction();
            this.JudgePageUrlArray.Clear();
            if (this.SourcePageUpArray.Count > 0)
            {
                for (int i = 0; i < this.SourcePageUpArray.Count; i++)
                {
                    if (!tracksaction.UrlRepeatJerqueFromArray(this.SourcePageDownArray, this.SourcePageUpArray[i].ToString()))
                    {
                        this.JudgePageUrlArray.Add(this.SourcePageUpArray[i].ToString());
                    }
                }
            }
        }

        private void FindLong(string C1, string C2)
        {
            int num = this.EInt - this.BInt;
            string sourcePageUp = this.SourcePageUp;
            string sourcePageDown = this.SourcePageDown;
            if (this.ReplaceContent.Length > 10)
            {
                sourcePageUp = sourcePageUp.Replace(this.ReplaceContent, "");
                sourcePageDown = sourcePageDown.Replace(this.ReplaceContent, "");
            }
            this.SourcePageUp = C1;
            this.SourcePageDown = C2;
            this.ExtractPageContent();
            if (num < (this.EInt - this.BInt))
            {
                num = this.EInt - this.BInt;
            }
            else
            {
                this.SourcePageUp = sourcePageUp;
                this.SourcePageDown = sourcePageDown;
            }
        }

        private string ImageSaveToDir(string ImageSaveToDirContent)
        {
            try
            {
                Get get = new Get();
                ArrayList pubContent = new RegexMy().RegexToArray("(?<=<img[^<>]+src=[\"']?)[^<>'\"\\s]+", ImageSaveToDirContent);
                if (pubContent.Count > 0)
                {
                    for (int i = 0; i < pubContent.Count; i++)
                    {
                        if (pubContent[i].ToString().Trim().Length > 10)
                        {
                            get.ImgSave(pubContent[i].ToString(), "NewsImages");
                            ImageSaveToDirContent = ImageSaveToDirContent.Replace(pubContent[i].ToString(), "/NewsImages" + Regex.Match(pubContent[i].ToString(), "\\/[^<>'\"\\/]+$").Value.ToString());
                        }
                    }
                    this.ImageSaveToDirChild = this.ImageSaveToDirChild + get.ArrayToBody(pubContent);
                }
                return ImageSaveToDirContent;
            }
            catch
            {
                return ImageSaveToDirContent;
            }
        }



        private void OrientationGoTo()
        {
            RegexMy my = new RegexMy();
            ArrayList list = my.RegexToArray(my.ExtractPageContent, this.SourcePageUp);
            string str = "";
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].ToString().Length > str.Length)
                {
                    str = list[i].ToString();
                }
            }
            if (this.SourcePageUp.IndexOf(str) != -1)
            {
                this.Orientation = this.SourcePageUp.IndexOf(str);
            }
            else
            {
                this.Orientation = 0;
            }
        }

        private string PageInterceptCauda(string PContent)
        {
            string[] strArray = new string[] { "[下一页]", "[1]", "下一页", "上一篇", "下一篇", "[上一页]", "上一页", "相关文章" };
            for (int i = 0; i < strArray.Length; i++)
            {
                if (PContent.IndexOf(strArray[i]) != -1)
                {
                    PContent = PContent.Substring(0, PContent.IndexOf(strArray[i]));
                }
            }
            return PContent;
        }

        private void ReplaceBlock(int PubBegin, int PubEnd)
        {
            try
            {
                int num;
                string str = "";
                bool flag = false;
                for (num = 0; num < ((this.AltCount + 1) * 3); num++)
                {
                    str = this.SourcePageUp.Substring(PubBegin, PubEnd + num);
                    if (this.SourcePageDown.IndexOf(str) == -1)
                    {
                        PubEnd += num - 1;
                        flag = true;
                        str = this.SourcePageUp.Substring(PubBegin, PubEnd);
                        break;
                    }
                }
                if (!flag)
                {
                    PubEnd += ((this.AltCount + 1) * 3) - 1;
                }
                flag = false;
                for (num = 0; num < ((this.AltCount + 1) * 3); num++)
                {
                    str = this.SourcePageUp.Substring(PubBegin - num, PubEnd + num);
                    if (this.SourcePageDown.IndexOf(str) == -1)
                    {
                        PubBegin = (PubBegin - num) + 1;
                        PubEnd = (PubEnd + num) - 1;
                        flag = true;
                        str = this.SourcePageUp.Substring(PubBegin, PubEnd);
                        break;
                    }
                }
                if (!flag)
                {
                    PubBegin -= ((this.AltCount + 1) * 2) - 1;
                    PubEnd += ((this.AltCount + 1) * 2) - 1;
                }
                this.ReplaceContent = this.SourcePageUp.Substring(PubBegin, PubEnd);
                this.ReplaceContent = this.ReplaceContentChild(this.ReplaceContent);
                this.SourcePageUp = this.SourcePageUp.Replace(this.ReplaceContent, "");
                this.SourcePageDown = this.SourcePageDown.Replace(this.ReplaceContent, "");
            }
            catch
            {
                this.ReplaceContent = "";
            }
        }

        private string ReplaceContentChild(string PubReplaceContentChild)
        {
            int index = PubReplaceContentChild.IndexOf("<");
            if (((index != -1) && (index > 0)) && (index < 20))
            {
                PubReplaceContentChild = PubReplaceContentChild.Substring(index, PubReplaceContentChild.Length - index);
            }
            index = PubReplaceContentChild.LastIndexOf(">");
            if (((index != -1) && (index > 0)) && (index < 20))
            {
                PubReplaceContentChild = PubReplaceContentChild.Substring(0, index);
            }
            return PubReplaceContentChild;
        }
    }